﻿Imports Castle.ActiveRecord
Imports NHibernate
Imports NHibernate.Criterion

Namespace Model
    <Serializable(), ActiveRecord("nf")> _
    Public Class NfPesquisa
        Inherits ActiveRecordBase(Of Model.NfPesquisa)

        'PK 
        Private _cd_nf As Integer

        'FKs
        Private _Cfop As Model.Cfop

        Private _nf_selecao As Boolean
        Private _nf_total As Decimal
        Private _nf_frete As Decimal
        Private _nf_thc As Decimal
        Private _nf_seguro As Decimal
        Private _nf_siscomex As Decimal
        Private _nf_despadu As Decimal
        Private _nf_prest_perc As Decimal
        Private _nf_prest_total As Decimal
        Private _nf_nfe_chave As String
        Private _nf_nfe_protocolo As String
        Private _nf_nfe_status As String
        Private _nf_nfe_processamento As String
        Private _nf_nfe_retorno_sefaz As String
        Private _nf_observacao As String

        <PrimaryKey(PrimaryKeyType.Sequence, SequenceName:="nf_cd_nf_seq")> _
        Public Property cd_nf() As Integer
            Get
                Return _cd_nf
            End Get
            Set(ByVal value As Integer)
                _cd_nf = value
            End Set
        End Property

        '<BelongsTo("cd_cfop")> _
        'Public Property Cfop() As Model.Cfop
        '    Get
        '        Return _Cfop
        '    End Get
        '    Set(ByVal value As Model.Cfop)
        '        _Cfop = value
        '    End Set
        'End Property
        Public Property nf_selecao() As Boolean
            Get
                Return _nf_selecao
            End Get
            Set(ByVal value As Boolean)
                _nf_selecao = value
            End Set
        End Property

        <[Property]("nf_total")> _
        Public Property nf_total() As Decimal
            Get
                Return _nf_total
            End Get
            Set(ByVal value As Decimal)
                _nf_total = value
            End Set
        End Property

        <[Property]("nf_frete")> _
        Public Property nf_frete() As Decimal
            Get
                Return _nf_frete
            End Get
            Set(ByVal value As Decimal)
                _nf_frete = value
            End Set
        End Property

        <[Property]("nf_thc")> _
        Public Property nf_thc() As Decimal
            Get
                Return _nf_thc
            End Get
            Set(ByVal value As Decimal)
                _nf_thc = value
            End Set
        End Property

        <[Property]("nf_seguro")> _
        Public Property nf_seguro() As Decimal
            Get
                Return _nf_seguro
            End Get
            Set(ByVal value As Decimal)
                _nf_seguro = value
            End Set
        End Property

        <[Property]("nf_siscomex")> _
        Public Property nf_siscomex() As Decimal
            Get
                Return _nf_siscomex
            End Get
            Set(ByVal value As Decimal)
                _nf_siscomex = value
            End Set
        End Property

        <[Property]("nf_despadu")> _
        Public Property nf_despadu() As Decimal
            Get
                Return _nf_despadu
            End Get
            Set(ByVal value As Decimal)
                _nf_despadu = value
            End Set
        End Property

        <[Property]("nf_prest_perc")> _
        Public Property nf_prest_perc() As Decimal
            Get
                Return _nf_prest_perc
            End Get
            Set(ByVal value As Decimal)
                _nf_prest_perc = value
            End Set
        End Property

        <[Property]("nf_prest_total")> _
        Public Property nf_prest_total() As Decimal
            Get
                Return _nf_prest_total
            End Get
            Set(ByVal value As Decimal)
                _nf_prest_total = value
            End Set
        End Property

        <[Property]("nf_nfe_chave")> _
        Public Property nf_nfe_chave() As String
            Get
                Return _nf_nfe_chave
            End Get
            Set(ByVal value As String)
                _nf_nfe_chave = value
            End Set
        End Property

        <[Property]("nf_nfe_protocolo")> _
        Public Property nf_nfe_protocolo() As String
            Get
                Return _nf_nfe_protocolo
            End Get
            Set(ByVal value As String)
                _nf_nfe_protocolo = value
            End Set
        End Property

        <[Property]("nf_nfe_status")> _
        Public Property nf_nfe_status() As String
            Get
                Return _nf_nfe_status
            End Get
            Set(ByVal value As String)
                _nf_nfe_status = value
            End Set
        End Property

        <[Property]("nf_nfe_processamento")> _
        Public Property nf_nfe_processamento() As String
            Get
                Return _nf_nfe_processamento
            End Get
            Set(ByVal value As String)
                _nf_nfe_processamento = value
            End Set
        End Property

        <[Property]("nf_nfe_retorno_sefaz")> _
        Public Property nf_nfe_retorno_sefaz() As String
            Get
                Return _nf_nfe_retorno_sefaz
            End Get
            Set(ByVal value As String)
                _nf_nfe_retorno_sefaz = value
            End Set
        End Property

        <[Property]("nf_observacao")> _
        Public Property nf_observacao() As String
            Get
                Return _nf_observacao
            End Get
            Set(ByVal value As String)
                _nf_observacao = value
            End Set
        End Property

        Public Function GetByOrderDesc() As IList(Of Model.NfPesquisa)

            'Dim q As DetachedCriteria = DetachedCriteria.For(Of Model.NfPesquisa).AddOrder(New Order("cd_nf", False))
            Dim order As NHibernate.Criterion.Order = New Order("cd_nf", False)

            Return Model.NfPesquisa.FindAll(order)
        End Function


    End Class
End Namespace